package com.yang.yangCommand;

import com.yang.YangCuiLian;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class YangCommand implements CommandExecutor {
    private YangCuiLian yangCuiLian;

    public YangCommand(YangCuiLian yangCuiLian) {
        this.yangCuiLian = yangCuiLian;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        //执行指令
        if(!label.equalsIgnoreCase("cuiLianGive")){
            return true;
        }
        if (args.length == 0){
            return true;
        }
        // 判断是否是玩家执行
        if (!(sender instanceof Player)) {
            return true;
        }
        String name = args[0];
        String wupin = args[1];
        Integer dengji = Integer.valueOf(args[2]);
        Integer shuliang = Integer.valueOf(args[3]);
        //把物品给玩家
        ItemStack itemStack = new ItemStack(Material.COAL);
        ItemMeta meta = itemStack.getItemMeta();
        List<String> loreList = new ArrayList<>();
        loreList.add("淬炼石 1 级");
        meta.setLore(loreList);
        meta.setLocalizedName("淬炼石 1 级");
        itemStack.setItemMeta(meta);
        Player aiyao = Bukkit.getPlayer("aiyao");
        aiyao.getInventory().addItem(itemStack);
        return true;
    }
}
